home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 4
/
The Arsenal Files 4 (Arsenal Computer).ISO
/
clarion
/
disabl.exe
/
CONTACTS.CLW
< prev
next >
Wrap
Text File
|
1995-01-05
|
19KB
|
533 lines
PROGRAM
MAP
CheckOpen(FILE,<BYTE>,<BYTE>)
ReportPreview
StandardWarning(LONG,<STRING>,<STRING>,<STRING>,<STRING>),LONG
RIUpdate:Status(STRING),LONG
RIDelete:Status,LONG
RIUpdate:contacts(STRING),LONG
RIDelete:contacts,LONG
MODULE('CONTA001.clw')
Main
END
MODULE('CONTA002.clw')
UpdateProc
END
MODULE('CONTA003.clw')
ReportByLastName
BrowseByLastName
END
MODULE('CONTA004.clw')
BrowseByCompany
ReportByCompany
END
MODULE('CONTA005.clw')
END
MODULE('CONTA006.clw')
BrowseByDate
END
MODULE('CONTA007.clw')
END
MODULE('CONTA008.clw')
END
MODULE('CONTA009.clw')
ReadMe
END
END
INCLUDE('Equates.CLW')
INCLUDE('Keycodes.CLW')
INCLUDE('Errors.CLW')
AppRef1 &WINDOW
savethread1 LONG
BrowseByCompanyOpen LONG(0)
BrowseByCompanyRef1 &WINDOW
ButtonRef1 LONG
ASCIIFileName CSTRING(80)
GlobalRequest LONG(0),THREAD
GlobalResponse LONG(0),THREAD
PrintPreviewQueue QUEUE
PrintPreviewImage STRING(80)
END
Status FILE,DRIVER('TOPSPEED'),PRE(STA),CREATE,THREAD
Key_Status KEY(STA:Status),NOCASE,OPT
Record RECORD
Status STRING(15)
END
END
Status::Used LONG,THREAD
contacts FILE,DRIVER('TOPSPEED'),PRE(CON),CREATE,THREAD
ID_Key KEY(CON:ID),NOCASE,OPT
Key_LastName KEY(CON:LastName),DUP,NOCASE
Key_Company KEY(CON:Company),DUP,NOCASE
Date_Lead_Received KEY(-CON:DateLead),DUP,NOCASE,OPT
Key_Car KEY(CON:TypeCar),DUP,NOCASE,OPT
Remarks MEMO(256)
Record RECORD
FirstName STRING(20)
ID STRING(4)
LastName STRING(20)
Company STRING(25)
Address1 STRING(25)
Address2 STRING(25)
City STRING(25)
State STRING(2)
Zip STRING(5)
Phone DECIMAL(10)
Fax DECIMAL(10)
JobTitle STRING(25)
Interest STRING(45)
TimeFrame STRING(15)
CurrentSoftware STRING(25)
TypeCar STRING(20)
DateLead STRING(8)
Status STRING(15)
END
END
contacts::Used LONG,THREAD
CODE
Main
CheckOpen PROCEDURE(File,OverrideCreate,OverrideOpenMode)
CODE
IF OMITTED(3)
OPEN(File,42h) !Attempt to open the file
ELSE
OPEN(File,OverrideOpenMode)
END
CASE ERRORCODE() ! and check for errors
OF NoError !Return if no error
OROF IsOpenErr ! or if already open.
DO ProcedureReturn
OF NoFileErr !If file was not found
IF OMITTED(2)
ELSIF OverrideCreate = TRUE
DO CreateFile
ELSE
IF StandardWarning(Warn:CreateError,NAME(File)).
END
OF InvalidFileErr !Invalid Record Declaration
IF StandardWarning(Warn:InvalidFile,NAME(File)).
OF BadKeyErr !Key Files must be rebuilt
IF StandardWarning(Warn:InvalidKey,NAME(File))
BUILD(File) !Rebuild the key files
END
IF ERRORCODE()
IF StandardWarning(Warn:RebuildError,NAME(File)).
ELSE
IF OMITTED(3)
OPEN(File,42h) !Attempt to open the file
ELSE
OPEN(File,OverrideOpenMode)
END
END
END !End of Case Structure
IF ERRORCODE()
IF StandardWarning(Warn:DiskError,NAME(File)) THEN HALT(0,'Disk Error').
END
DO ProcedureReturn
ProcedureReturn ROUTINE
RETURN
CreateFile ROUTINE
CREATE(File) !Create the file
IF ERRORCODE()
IF ERRORCODE() = 90
IF StandardWarning(Warn:CreateError,NAME(File)).
ELSE
IF StandardWarning(Warn:CreateError,NAME(File)).
END
END
IF OMITTED(3)
OPEN(File,42h) !Attempt to open the file
ELSE
OPEN(File,OverrideOpenMode)
END
IF ~ERRORCODE() ! And return if it opened
DO ProcedureReturn
ELSE
IF StandardWarning(Warn:CreateOpenError,NAME(File)).
END
ReportPreview PROCEDURE
LeftPageNumber SHORT,AUTO
PreviewWindow WINDOW('Print Preview'),AT(,,316,218),CENTER,SYSTEM,GRAY
BOX,AT(5,5,150,178),COLOR(00H)
IMAGE(),AT(5,5,150,178),USE(?Image1)
STRING(''),AT(95,185,55,10),USE(?Image1Page),RIGHT
BOX,AT(160,5,150,178),COLOR(00H)
IMAGE(),AT(160,5,150,178),USE(?Image2)
STRING(''),AT(250,185,50,10),USE(?Image2Page),RIGHT
BUTTON('&Previous Page'),AT(5,200,55,14),USE(?PreviewPreviousPage)
BUTTON('&Next Page'),AT(65,200,55,14),USE(?PreviewNextPage)
BUTTON('&Print'),AT(185,200,55,14),USE(?PreviewPrint)
BUTTON('&Close'),AT(245,200,55,14),USE(?PreviewClose)
END
CODE
OPEN(PreviewWindow)
LeftPageNumber = 1
DO LoadPages
ACCEPT
CASE FIELD()
OF ?PreviewClose
IF Event() = Event:Accepted
GlobalResponse = RequestCancelled
POST(Event:CloseWindow)
END
OF ?PreviewPrint
IF Event() = Event:Accepted
GlobalResponse = RequestCompleted
POST(Event:CloseWindow)
END
OF ?PreviewPreviousPage
IF Event() = Event:Accepted
LeftPageNumber -= 2
DO LoadPages
END
OF ?PreviewNextPage
IF Event() = Event:Accepted
LeftPageNumber += 2
DO LoadPages
END
END
END
RETURN
LoadPages ROUTINE
IF LeftPageNumber = 1
?PreviewPreviousPage{Prop:Disable}=True
ELSE
?PreviewPreviousPage{Prop:Disable}=False
END
GET(PrintPreviewQueue,LeftPageNumber)
?Image1{Prop:Text} = PrintPreviewImage
?Image1Page{Prop:Text} = 'Page ' & LeftPageNumber
IF LeftPageNumber = RECORDS(PrintPreviewQueue)
?PreviewNextPage{Prop:Disable}=True
?Image2Page{Prop:Text} = ''
?Image2{Prop:Hide} = True
ELSIF LeftPageNumber = RECORDS(PrintPreviewQueue) - 1
?PreviewNextPage{Prop:Disable}=True
GET(PrintPreviewQueue,LeftPageNumber+1)
?Image2{Prop:Text} = PrintPreviewImage
?Image2Page{Prop:Text} = 'Page ' & LeftPageNumber+1
?Image2{Prop:Hide} = False
ELSE
?PreviewNextPage{Prop:Disable}=False
GET(PrintPreviewQueue,LeftPageNumber+1)
?Image2{Prop:Text} = PrintPreviewImage
?Image2Page{Prop:Text} = 'Page ' & LeftPageNumber+1
?Image2{Prop:Hide} = False
END
StandardWarning FUNCTION(WarningID,WarningText1,WarningText2,WarningText3,WarningText4)
ErrorText STRING(150),AUTO
ReturnValue LONG
CODE
IF ERRORCODE() <> 90
ErrorText = CLIP(ERROR()) & ' (' & ERRORCODE() & ')'
ELSE
ErrorText = CLIP(FILEERROR()) & ' (' & CLIP(FILEERRORCODE()) & ')'
END
CASE WarningID
OF Warn:InvalidFile
IF MESSAGE('Error: (' & CLIP(ErrorText) & ') accessing ' |
& CLIP(WarningText1) & '. Press OK to end this application.'|
,'Invalid File',ICON:Exclamation,Button:OK,BUTTON:OK,0).
HALT(0,'Invalid File!')
OF Warn:InvalidKey
IF MESSAGE(CLIP(WarningText1) & ' key file is invalid. Do you '|
&'want to rebuild the key?','Invalid Key',Icon:Question,|
Button:Yes+Button:No,Button:Yes,0)=Button:No
HALT(0,'Invalid Key!')
ELSE
RETURN(Button:Yes)
END
OF Warn:RebuildError
IF MESSAGE('Error: (' & CLIP(ErrorText) & ') repairing key for ' |
& CLIP(WarningText1) & '. Press OK to end this application.',|
'Key Rebuild Error',ICON:Exclamation,Button:OK,BUTTON:OK,0).
HALT(0,'Error Rebuilding Key!')
OF Warn:CreateError
IF MESSAGE('Error: (' & CLIP(ErrorText) & ') creating ' |
& CLIP(WarningText1) & '. Press OK to end this application.',|
'File Creation Error',ICON:Exclamation,Button:OK,BUTTON:OK,0).
HALT(0,'File Creation Error!')
OF Warn:CreateOpenError
IF MESSAGE('Error: (' & CLIP(ErrorText) & ') opening created ' |
& 'file:' & CLIP(WarningText1) & '. Press OK to end this application.',|
'File Creation Error',ICON:Exclamation,Button:OK,BUTTON:OK,0).
HALT(0,'File Creation Error!')
OF Warn:ProcedureToDo
RETURN(MESSAGE('The Procedure ' & CLIP(WarningText1) & 'has not '|
&'been defined.','Procedure not defined',ICON:Exclamation,|
Button:OK,BUTTON:OK,0))
OF Warn:BadKeyedRec
RETURN(MESSAGE('Unable to read keyed record. Error: ' |
& CLIP(ErrorText) & '. Insert Aborted',ICON:Exclamation,|
Button:OK,Button:OK,0))
OF Warn:OutOfRangeHigh
RETURN(MESSAGE('The value of ' & CLIP(WarningText1) & ' must'|
&' be lower than ' & CLIP(WarningText2) & '.','Range Error',|
ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:OutOfRangeLow
RETURN(MESSAGE('The value of ' & CLIP(WarningText1) & ' must be'|
&' higher than ' & CLIP(WarningText2) & '.','Range Error',|
ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:OutOfRange
RETURN(MESSAGE('The value of ' & CLIP(WarningText1) & ' must be '|
&'between ' & CLIP(WarningText2) & ' and ' & CLIP(WarningText3) |
& '.','Range Error',ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:NotInFile
RETURN(MESSAGE('The value for ' & CLIP(WarningText1) & ' must be '|
&'found in the ' & CLIP(WarningText2) & ' file.','Field Contents '|
&'Error',ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:RestrictUpdate
RETURN(MESSAGE('This record is referenced from the file '|
& CLIP(WarningText1) & '. Linking field(s) have been restricted'|
& ' from change and have been reset to original values.',|
'Referential Integrity Update Error',ICON:Exclamation,|
Button:OK,Button:OK,0))
OF Warn:RestrictDelete
RETURN(MESSAGE('This record is referenced from the file '|
& CLIP(WarningText1) & '. This record cannot be deleted while'|
& ' these references exist.','Referential Integrity Delete Error'|
,ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:InsertError
RETURN(MESSAGE('An error was experienced during the update of'|
& ' record. Error: ' & CLIP(ErrorText) & '.'|
,'Record Insert Error'|
,ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:RIUpdateError
RETURN(MESSAGE('An error (' & CLIP(ErrorText) & ') was experienced'|
&' when attempting to update a record from the file. Probable Cause: ' |
& CLIP(WarningText1) & '.','Update Operation Error',Icon:Exclamation,|
Button:OK,Button:OK,0))
OF Warn:UpdateError
RETURN(MESSAGE('An error was experienced changing this record. '|
&'Do you want to try to save again?','Record Update Error',|
Icon:Exclamation,Button:Yes+Button:No+Button:Cancel,Button:Cancel,0))
OF Warn:RIDeleteError
RETURN(MESSAGE('An error (' & CLIP(ErrorText) & ') was experienced'|
&' when attempting to delete a record from the file ' |
& CLIP(WarningText1) & '.','Delete Operation Error',Icon:Exclamation,|
Button:OK,Button:OK,0))
OF Warn:DeleteError
RETURN(MESSAGE('An error was experienced deleting this record. '|
&'Do you want to try to save again?','Record Update Error',|
Icon:Exclamation,Button:Yes+Button:No+Button:Cancel,Button:Cancel,0))
OF Warn:InsertDisabled
RETURN(MESSAGE('This procedure was called to insert a record, '|
& 'however inserts are not allowed for this procedure. Press OK '|
& 'to return to the calling procedure','Invalid Request',|
Icon:Exclamation,Button:OK,Button:OK,0))
OF Warn:UpdateDisabled
RETURN(MESSAGE('This procedure was called to change a record, '|
& 'however changes are not allowed for this procedure. Press OK '|
& 'to return to the calling procedure','Invalid Request',|
ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:DeleteDisabled
RETURN(MESSAGE('This procedure was called to delete a record, '|
& 'however deletions are not allowed for this procedure. Press OK '|
& 'to return to the calling procedure','Invalid Request',|
ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:NoCreate
IF MESSAGE('The File ' & CLIP(WarningText1) & 'was not found, '|
&'and creation of the file is not allowed. Press OK to end '|
&'this application.','File Creation Not Allowed',ICON:Exclamation,|
Button:OK,BUTTON:OK,0)
HALT(0,'File Creation Error!')
END
OF Warn:ConfirmCancel
RETURN(MESSAGE('Do you want to save the changes to this record?'|
,'Update Cancelled',ICON:Question,Button:Yes+Button:No+Button:Cancel,|
Button:No,0))
OF Warn:DuplicateKey
RETURN(MESSAGE('Adding this record creates a duplicate entry '|
&'for the key:' & CLIP(WarningText1),'Duplicate Key Error',|
ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:AutoIncError
RETURN(MESSAGE('Attempts to automatically number this record have '|
&'failed. Error: ' & CLIP(ErrorText) & '.',|
'Auto Increment Error',Icon:Exclamation,Button:Cancel+Button:Retry,|
Button:Cancel,0))
OF Warn:FileLoadError
RETURN(MESSAGE(CLIP(WarningText1) & ' File Load Error. '|
&'Error: ' & CLIP(ErrorText) & '.','File Load Error',ICON:Exclamation,|
Button:OK,Button:OK,0))
OF Warn:ConfirmCancelLoad
RETURN(MESSAGE('Are you certain you want to stop loading ' |
& CLIP(WarningText1) & '?','Cancel Request',|
ICON:Question,Button:OK+Button:Cancel,Button:Cancel,0))
OF Warn:FileZeroLength
RETURN(MESSAGE(CLIP(WarningText1) & ' File Load Error. '|
&'The file you''ve requested contains no text.','File Load Error',|
ICON:Exclamation,Button:OK,Button:OK,0))
OF Warn:EndOfASCIIQueue
IF WarningText1 = 'Down'
RETURN(MESSAGE('The end of the viewed file was encountered. '|
& 'Do you want to start again from the beginning?',|
'End of File Error',ICON:Question,Button:Yes+Button:No,Button:Yes,0))
ELSE
RETURN(MESSAGE('The beginning of the viewed file was encountered. '|
& 'Do you want to start again from the end of the file?',|
'Beginning of File Error',ICON:Question,Button:Yes+Button:No,|
Button:Yes,0))
END
OF Warn:DiskError
RETURN(MESSAGE('File (' & CLIP(WarningText1) & ') could not be '|
& 'opened. Error: ' & CLIP(ErrorText) & '.','File Access Error'|
,Icon:Exclamation,Button:OK,Button:OK,0))
OF Warn:ProcessActionError
IF WarningText1 = 'Put'
RETURN(MESSAGE('An error was experienced when making changes'|
& ' to the ' & CLIP(WarningText2) & ' file. Error: '|
& CLIP(ErrorText),'Process PUT Error',Icon:Exclamation|
,Button:OK,Button:OK,0))
ELSE
RETURN(MESSAGE('An error was experienced when deleting a record'|
& ' from the ' & CLIP(WarningText2) & ' file. Error: '|
& CLIP(ErrorText),'Process DELETE Error',Icon:Exclamation|
,Button:OK,Button:OK,0))
END
END
!--------------------------------------------------
RIUpdate:Status FUNCTION(Passed:Buffer)
Process:Buffer LIKE(STA:Record),PRE(RP),OVER(Passed:Buffer)
Current:Buffer LIKE(STA:Record),PRE(RC)
Current:Position STRING(512)
CODE
Current:Position = POSITION(STA:Key_Status)
Current:Buffer = STA:Record
LOGOUT(2,Status)
REGET(STA:Key_Status,Current:Position)
IF ERRORCODE()
IF StandardWarning(Warn:RIUpdateError,'Record Changed/Deleted by Another Station')
ROLLBACK()
DO RICloseFiles
RETURN(1)
END
END
IF STA:Record <> Passed:Buffer
IF StandardWarning(Warn:RIUpdateError,'Record Changed by Another Station')
ROLLBACK()
DO RICloseFiles
RETURN(1)
END
END
STA:Record = Current:Buffer
PUT(Status)
IF ERRORCODE()
IF StandardWarning(Warn:RIUpdateError,'Status')
ROLLBACK
DO RICloseFiles
RETURN(1)
END
ELSE
COMMIT
DO RICloseFiles
RETURN(0)
END
!----------------------------------------------------------------------
RICloseFiles ROUTINE
EXIT
!--------------------------------------------------
RIDelete:Status FUNCTION
Current:Position STRING(512)
CODE
Current:Position = POSITION(STA:Key_Status)
LOGOUT(2,Status)
REGET(STA:Key_Status,Current:Position)
DELETE(Status)
IF ERRORCODE()
IF StandardWarning(Warn:RIDeleteError,'Status')
ROLLBACK
DO RICloseFiles
RETURN(1)
END
ELSE
COMMIT
DO RICloseFiles
RETURN(0)
END
!----------------------------------------------------------------------
RICloseFiles ROUTINE
EXIT
!--------------------------------------------------
RIUpdate:contacts FUNCTION(Passed:Buffer)
Process:Buffer LIKE(CON:Record),PRE(RP),OVER(Passed:Buffer)
Current:Buffer LIKE(CON:Record),PRE(RC)
Current:Position STRING(512)
Current:CON:Remarks LIKE(CON:Remarks)
CODE
Current:Position = POSITION(CON:ID_Key)
Current:Buffer = CON:Record
Current:CON:Remarks = CON:Remarks
LOGOUT(2,contacts)
REGET(CON:ID_Key,Current:Position)
IF ERRORCODE()
IF StandardWarning(Warn:RIUpdateError,'Record Changed/Deleted by Another Station')
ROLLBACK()
DO RICloseFiles
RETURN(1)
END
END
IF CON:Record <> Passed:Buffer
IF StandardWarning(Warn:RIUpdateError,'Record Changed by Another Station')
ROLLBACK()
DO RICloseFiles
RETURN(1)
END
END
CON:Record = Current:Buffer
CON:Remarks = Current:CON:Remarks
PUT(contacts)
IF ERRORCODE()
IF StandardWarning(Warn:RIUpdateError,'contacts')
ROLLBACK
DO RICloseFiles
RETURN(1)
END
ELSE
COMMIT
DO RICloseFiles
RETURN(0)
END
!----------------------------------------------------------------------
RICloseFiles ROUTINE
EXIT
!--------------------------------------------------
RIDelete:contacts FUNCTION
Current:Position STRING(512)
CODE
Current:Position = POSITION(CON:ID_Key)
LOGOUT(2,contacts)
REGET(CON:ID_Key,Current:Position)
DELETE(contacts)
IF ERRORCODE()
IF StandardWarning(Warn:RIDeleteError,'contacts')
ROLLBACK
DO RICloseFiles
RETURN(1)
END
ELSE
COMMIT
DO RICloseFiles
RETURN(0)
END
!----------------------------------------------------------------------
RICloseFiles ROUTINE
EXIT